package com.jiamao.goplay.ui.msg.vm;

import android.os.Bundle;

import com.jiamao.goplay.bean.BaseUserInfo;
import com.jiamao.goplay.bean.InviteMeListItme;
import com.jiamao.goplay.bean.res.ResMessage;
import com.jiamao.goplay.ui.user.OthersUserInfoFragment;
import com.jiamao.goplay.ui.user.UserInvitationFragment;
import com.jiamao.goplay.ui.user.vm.UserInvitationVM;

import androidx.annotation.NonNull;

import androidx.databinding.ObservableField;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.utils.KLog;
import me.goldze.mvvmhabit.utils.ToastUtils;

public class MsgItemVM extends MultiItemViewModel {

    public ObservableField<String> imgUrl = new ObservableField<>("");
    public ObservableField<String> name = new ObservableField<>("");
    public ObservableField<String> addr = new ObservableField<>("");
    public ObservableField<String> nums = new ObservableField<>("");
    public ObservableField<String> numsStr = new ObservableField<>("");
    private String uid;
    public MsgItemVM(@NonNull BaseViewModel viewModel, ResMessage.ParfItme item) {
        super(viewModel);
        if (item  == null){
            return;
        }
        uid = item.getUid();
      //  KLog.d("item.getAvatar() "+item.getAvatar());
        imgUrl.set(item.getAvatar());
        name.set(item.getNickname());
        addr.set(item.getPlaceName());
    }
    public MsgItemVM(@NonNull BaseViewModel viewModel,ResMessage.InviteInfo item) {
        super(viewModel);
        if (item  == null){
            return;
        }
        KLog.d(item.getAvatar()+  "      aaaasa");
        imgUrl.set(item.getAvatar());
        if (item.getInviteNum()>99){
            nums.set("99+");
        }else if (item.getInviteNum()==0){
            nums.set("");
        }else{
            nums.set(item.getInviteNum()+"");
        }
        //nums.set(item.getInviteNum()+"");
        numsStr.set("有"+item.getInviteNum()+"个待处理");
    }
    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bd  = new Bundle();
            bd.putString("uid",uid);
            viewModel.startContainerActivity(OthersUserInfoFragment.class.getCanonicalName(),bd);
            // ToastUtils.showShort("我是头布局");
        }
    });

    //条目的点击事件
    public BindingCommand yqClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {

            viewModel.startContainerActivity(UserInvitationFragment.class.getCanonicalName());
//            ToastUtils.showShort("ta");
        }
    });
}
